<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>卡牌分组</title>
</head>
<body>
  <script>
    function fn(deck) {
      function gcd(x, y) {
        return x == 0 ? y : gcd(y % x, x);
      }
      let obj = {};
      for (let i of deck) {
        obj[i] = !obj[i] ? 1 : ++obj[i];
      }
      let arr = Object.values(obj);
      let res = arr[0];
      return arr.every(i => (res = gcd(res, i)) > 1);
    }
    console.log(fn([1, 1, 1, 2, 2, 2, 3, 3]))
  </script>
</body>
</html>